package com.heima.controller.vm_service;

import com.heima.pojo.dto.NodeSaveDto;
import com.heima.pojo.entity.Node;
import com.heima.pojo.entity.TbVmType;
import com.heima.pojo.vo.PageVo;
import com.heima.service.VmTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vm-service/vmType")
@Slf4j
public class VmTypeController {
    @Autowired
    private VmTypeService vmTypeService;
    /**
     * 设备搜索
     * 分页条件查询
     */
    @GetMapping("/search")
    public PageVo nodePage(@RequestParam Integer pageIndex, Integer pageSize,
                           @RequestParam(required = false) String name){
        PageVo nodePageVos=  vmTypeService.getTypePage(pageIndex,pageSize,name);
        return nodePageVos;
    }

    /**
     * 新增设备类型
     */
    @PostMapping
    public Boolean save(@RequestBody TbVmType type){
        return vmTypeService.save(type);
    }

    /**
     * 修改设备
     */
    @PutMapping("/{typeId}")
    public Boolean update(@PathVariable Integer typeId, @RequestBody TbVmType type){
        return vmTypeService.update(typeId,type);
    }
    /**
     * 删除设备
     */
    @DeleteMapping("/{typeId}")
    public Boolean delete(@PathVariable Integer typeId){
        return vmTypeService.delete(typeId);
    }

}
